package com.miaowang.salad.jobqueue;

/**
 * Created by Administrator on 2015/6/30.
 */
public class JobEvents {
	/**
	 * Account job events
	 */
	public static final int USER_EVENT_BASE = 0;
	public static final int LOGIN = USER_EVENT_BASE + 1;
	public static final int LOGOUT = USER_EVENT_BASE + 2;
	public static final int SEND_PHONE_IDENTIFY_CODE = USER_EVENT_BASE + 3;
	public static final int GET_CURRENT_TASK = USER_EVENT_BASE + 4;
	public static final int SEND_SERVICE_REQUESTS = USER_EVENT_BASE + 5;
	public static final int SEND_SERVICE_REQUESTS_SUCCESS = USER_EVENT_BASE + 6;
	public static final int GET_SERVICE_REQUESTS = USER_EVENT_BASE + 7;
	public static final int GET_SERVICE_REQUESTS_ID = USER_EVENT_BASE + 8;
	public static final int GET_SERVICE_REQUESTS_ID_CURRENT = USER_EVENT_BASE + 9;
	public static final int GET_RESCUE_LOCATION = USER_EVENT_BASE + 10;
	public static final int GET_MY_INFO = USER_EVENT_BASE + 11 ;
	public static final int GET_MY_INFO_BEGIN = USER_EVENT_BASE + 12 ;
	public static final int SEND_MY_INFO = USER_EVENT_BASE + 13;
	public static final int CANCEL_SERVICE_REQUESTS = USER_EVENT_BASE + 14;
	

	public enum Error {
		/**
		 * An IOException occurred while communicating to the server.
		 */
		NETWORK,
		/**
		 * An exception was thrown while (de)serializing a body.
		 */
		CONVERSION,
		/**
		 * A non-200 HTTP status code was received from the server.
		 */
		HTTP,
		/**
		 * An internal error occurred while attempting to execute a request. It
		 * is best practice to re-throw this exception so your application
		 * crashes.
		 */
		UNEXPECTED,
		/**
		 * A 401 HTTP status code was received from the server.
		 */
		UNAUTHORIZED,
	}

	public static class JobSuccess<T> {
		private T result;
		private int jobCode;

		public JobSuccess(int jobCode) {
			this(jobCode, null);
		}

		public JobSuccess(int jobCode, T r) {
			this.jobCode = jobCode;
			result = r;
		}

		public T getResult() {
			return result;
		}

		public int getJobCode() {
			return jobCode;
		}
	}

	public static class JobFailure {
		private Error error;
		private String errMsg;
		private int jobCode;

		public JobFailure(int jobCode) {
			this(jobCode, null);
		}

		public JobFailure(int job, Error error) {
			this(job, error, null);
		}

		public JobFailure(int jobCode, Error error, String errMsg) {
			this.jobCode = jobCode;
			this.error = error;
			this.errMsg = errMsg;
		}

		public final Error getError() {
			return error;
		}

		public final String getErrMsg() {
			return errMsg;
		}

		public int getJobCode() {
			return jobCode;
		}
	}

}
